﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;

namespace HQWeb.Wbserver
{
    /// <summary>
    /// GetSmartTips 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
     [System.Web.Script.Services.ScriptService]
    public class GetSmartTips : System.Web.Services.WebService
    {

        #region 智能提示用户姓名
        [WebMethod(Description="智能提示用户姓名")]
        public string[] GetUserName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.SysManage.T_PUB_USER bll = new BLL.SysManage.T_PUB_USER();
            List<string> list = new List<string>();
            dt = bll.GetUserName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示部门名称
        [WebMethod(Description = "智能提示部门名称")]
        public string[] GetDepartmentName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.SysManage.T_PUB_DEPARTMENT bll = new BLL.SysManage.T_PUB_DEPARTMENT();
            List<string> list = new List<string>();
            dt = bll.GetDepartmentName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示菜单名称
        [WebMethod(Description = "智能提示菜单名称")]
        public string[] GetMenuName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.SysManage.T_PUB_MENU bll = new BLL.SysManage.T_PUB_MENU();
            List<string> list = new List<string>();
            dt = bll.GetMenuName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示元素名称
        [WebMethod(Description = "智能提示元素名称")]
        public string[] GetMaterialName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.SysManage.T_PUB_MATERIAL bll = new BLL.SysManage.T_PUB_MATERIAL();
            List<string> list = new List<string>();
            dt = bll.GetMaterialName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示元素类型名称
        [WebMethod(Description = "智能提示元素类型名称")]
        public string[] GetMaterialTypeName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.SysManage.T_PUB_MATERIALTYPE bll = new BLL.SysManage.T_PUB_MATERIALTYPE();
            List<string> list = new List<string>();
            dt = bll.GetMaterialTypeName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示主题婚礼名称
        [WebMethod(Description = "智能提示主题婚礼名称", EnableSession=true)]
        public string[] GetThemeWeddingTitel(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.SysManage.T_PUB_WEDDINGTHEME bll = new BLL.SysManage.T_PUB_WEDDINGTHEME();
            List<string> list = new List<string>();
            if (Session["IsAll"] != null)
            {
                if (Convert.ToBoolean(Session["IsAll"]) == false)
                {
                    int branch_id = Convert.ToInt32(Session["BRANCH_ID"]);
                    dt = bll.GetThemeWeddingTitel(branch_id).Tables[0];
                }
                else
                {
                    dt = bll.GetThemeWeddingTitel().Tables[0];
                }
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示酒店名称
        [WebMethod(Description = "智能提示酒店名称")]
        public string[] GetHotelName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.SysManage.T_PUB_HOTEL bll = new BLL.SysManage.T_PUB_HOTEL();
            List<string> list = new List<string>();
            dt = bll.GetHotelName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示项目名称
        [WebMethod(Description = "智能提示项目名称", EnableSession = true)]
        public string[] GetProjectName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.Progect.T_PUB_PROJECT bll = new BLL.Progect.T_PUB_PROJECT();
            List<string> list = new List<string>();
            dt = bll.GetProjectName().Tables[0]; 
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示文件名称
        [WebMethod(Description = "智能提示文件名称", EnableSession = true)]
        public string[] GetFileTitel(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.Progect.T_PUB_FILE bll = new BLL.Progect.T_PUB_FILE();
            List<string> list = new List<string>();
            if (Session["IsAll"] != null)
            {
                if (Convert.ToBoolean(Session["IsAll"]) == false)
                {
                    int branch_id = Convert.ToInt32(Session["BRANCH_ID"]);
                    dt = bll.GetFileTitel(branch_id).Tables[0];
                }
                else
                {
                    dt = bll.GetFileTitel().Tables[0];
                }
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示项目类型名称
        [WebMethod(Description = "智能提示项目类型名称")]
        public string[] GetProjectTypeName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.SysManage.T_PUB_PROJECTTYPE bll = new BLL.SysManage.T_PUB_PROJECTTYPE();
            List<string> list = new List<string>();
            dt = bll.GetProjectTypeName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示客户姓名
        [WebMethod(Description = "智能提示客户姓名")]
        public string[] GetCustomerName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.View.T_PUB_CUSTOMERINFO bll = new BLL.View.T_PUB_CUSTOMERINFO();
            List<string> list = new List<string>();
            dt = bll.GetCustomerName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
                s = dt.Rows[i][1].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示客户新郎姓名
        [WebMethod(Description = "智能提示客户新郎姓名")]
        public string[] GetGroomName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.View.T_PUB_CUSTOMERINFO bll = new BLL.View.T_PUB_CUSTOMERINFO();
            List<string> list = new List<string>();
            dt = bll.GetGroomName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        #region 智能提示客户新娘姓名
        [WebMethod(Description = "智能提示客户新娘姓名")]
        public string[] GetBrideName(string prefixText, int count)
        {
            string s;
            DataTable dt = new DataTable();
            BLL.View.T_PUB_CUSTOMERINFO bll = new BLL.View.T_PUB_CUSTOMERINFO();
            List<string> list = new List<string>();
            dt = bll.GetBrideName().Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                s = dt.Rows[i][0].ToString();
                if (s.StartsWith(prefixText))
                {
                    list.Add(s);
                }
            }
            return list.ToArray();
        }
        #endregion

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
    }
}
